from urllib.request import urlretrieve
from bs4 import BeautifulSoup
import requests

def geturl(url):
    html=requests.get(url)
    bs=BeautifulSoup(html.text,'html.parser')
    return bs

def f1(url):
    bs=geturl(url)
    x=bs.find('div',{'class':'weui-weixin-content'}).find_all(href=True)
    for xx in x:
        f2(xx['href'])

def f2(url):
    bs=geturl(url)
    print(bs)
    xx=bs.find('div',{'class':'container-fluid container-fluid-content'}).find_all(src=True)
    t=1
    for x in xx:
        urlretrieve(x['src'],'{}.{}.jpg'format(bs.title,t))
        t+=1
        print(x['src'])

url=input('输入物理学（第六版）学生样章_马文蔚首页链接：')
f1(url)
